package com.zy.edu.controller;


import com.zy.edu.bean.Classinfo;
import com.zy.edu.bean.InputParam;
import com.zy.edu.service.ClassinfoService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-07-13
 */
@RestController
@RequestMapping("/classinfo")
public class ClassinfoController {
    @Resource
    ClassinfoService classinfoService;

    /**
     * @Author: HuangHaiShui
     * @Description: 数据的新增与修改
     * @Date: 9:17 2021/7/14
     * @param classinfo:
     * @return: Map
     **/
    @RequestMapping("/edit")
    public Map edit(@Valid Classinfo classinfo,InputParam inputParam){
        return classinfoService.saveOrUpdate(classinfo,inputParam);
    }

    /**
     * @Author: HuangHaiShui
     * @Description:数据数据的查询，可分页可查全部
     * @Date: 9:17 2021/7/14
     * @param classinfo:    name 模糊查询
     * @param inputParam:  分页条件
     * @return: Map
     **/
    @RequestMapping("/list")
    public Map list( Classinfo classinfo, InputParam inputParam){

        return classinfoService.list(classinfo, inputParam);
    }

    @RequestMapping("/getById")
    public Map getById( Classinfo classinfo, InputParam inputParam){

        return classinfoService.getById(classinfo, inputParam);
    }

    /**
     * @Author: HuangHaiShui
     * @Description:三级联动  根据校区查询班级
     * @Date: 9:38 2021/7/20
     * @param schoolId:
     * @param userId:
     * @return: Map
     **/
    @RequestMapping("/getBySchoolId")
    public Map getBySchoolId( String schoolId, String userId){

        return classinfoService.getBySchoolId(schoolId, userId);
    }



    /**
     * @Author: HuangHaiShui
     * @Description: 删除数据
     * @Date: 9:18 2021/7/14
     * @param classinfo:  传入id 字段
     * @return: Map
     **/
    @RequestMapping("/dele")
    public Map dele( Classinfo classinfo){
        return classinfoService.dele(classinfo);
    }


    //班级关联课程
    @RequestMapping("course")
    public Map course(  InputParam inputParam ) throws Exception {

        return classinfoService.associatedCourse(inputParam);
    }

    /**
     * @Author: HuangHaiShui
     * @Description:获取该班级已关联的课程id
     * @Date: 14:30 2021/7/29
     * @param inputParam:
     * @return: Map
     **/
    @RequestMapping("getCourse")
    public Map getCourseByClassId(  InputParam inputParam ) throws Exception {

        return classinfoService.getCourseByClassId(inputParam);
    }

    /**
     * @Author: HuangHaiShui
     * @Description:获取该班级已关联的课程所有信息
     * @Date: 14:30 2021/7/29
     * @param inputParam:
     * @return: Map
     **/
    @RequestMapping("getAllCourse")
    public Map getAllCourseClassId(  InputParam inputParam ) throws Exception {

        return classinfoService.getAllCourseClassId(inputParam);
    }
}

